/*
 * HandMatrix.cpp
 *
 *  Created on: 21 May 2012
 *      Author: rveitch
 */

#include <iostream>

#include "HandMatrix.h"

HandMatrix::HandMatrix(const std::string& filename)
	: csv(filename){

	csv.readLine();//skip the first line which is just card names

	for (int iii=0 ; iii<13 ; iii++){
		std::vector<int> intVec = csv.readLineInts();

		for (int jjj=1 ; jjj<intVec.size(); jjj++){
			matrix[jjj-1][iii] = intVec[jjj];
		}
	}
}

HandMatrix::~HandMatrix() {
}

int HandMatrix::getM(Card c0, Card c1){
	bool suited = c0.getSuit()==c1.getSuit();
	CardDeck::Face lowerFace = minFace(c0, c1);
	CardDeck::Face higherFace = maxFace(c0, c1);

	if (suited){
		return matrix[higherFace][lowerFace];
	}else{
		return matrix[lowerFace][higherFace];
	}
}
